package com.ehome.poct.core.controller;

import com.ehome.poct.core.api.dto.patient.AddPatientDTO;
import com.ehome.poct.core.api.dto.patient.EditPatientDTO;
import com.ehome.poct.core.api.dto.patient.TermPatientDTO;
import com.ehome.poct.core.api.virtual.PatientService;
import com.ehome.poct.core.api.vo.patient.PatientDetailVO;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 患者
 *
 * @author muqiu
 * @since 2022/03/02 11:20
 **/
@Api(tags = "患者管理")
@ApiSupport(author = "muqiu")
@RequestMapping("/patient")
@RestController
@AllArgsConstructor
public class PatientController{

    @Autowired private final PatientService patientService;

    @ApiOperation("添加患者")
    @ApiOperationSupport(author = "muqiu")
    @PostMapping("/patient/add")
    public PatientDetailVO patientAdd(@RequestBody AddPatientDTO addPatientDto) {
        return patientService.addPatient(addPatientDto);
    }

    @ApiOperation("修改患者")
    @ApiOperationSupport(author = "muqiu")
    @PutMapping("/patient/edit")
    public PatientDetailVO patientEdit(@RequestBody EditPatientDTO editPatientDto) {
       return  patientService.editPatient(editPatientDto);
    }

    @ApiOperation("查看患者详情")
    @ApiOperationSupport(author = "muqiu")
    @GetMapping("/patient/get/{patientId}")
    public PatientDetailVO patientGet(@PathVariable Long patientId) {
        return patientService.getPatient(patientId);
    }

    @ApiOperation("查看患者详情")
    @ApiOperationSupport(author = "muqiu")
    @GetMapping("/patient/getById/{patientId}")
    public TermPatientDTO getByPatientId(@PathVariable Long patientId) {
        return patientService.getPatientById(patientId);
    }

}